package com.ruoyi.web.controller.food;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.entity.Result;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.IotCubeElectricityConsumptionHistory;
import com.ruoyi.system.service.IIotCubeElectricityConsumptionHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * IoT数据_六面控温用电量记录Controller
 * 
 * @author ruoyi
 * @date 2025-04-02
 */
@RestController
@RequestMapping("/web/electricity/history")
@Api(tags = "IoT数据_六面控温用电量记录")
public class IotCubeElectricityConsumptionHistoryController extends BaseController<IotCubeElectricityConsumptionHistory>
{
    @Autowired
    private IIotCubeElectricityConsumptionHistoryService iotCubeElectricityConsumptionHistoryService;

    /**
     * 查询IoT数据_六面控温用电量记录列表-分页
     */
    @ApiOperation(value = "查询IoT数据_六面控温用电量记录列表-分页")
    @PreAuthorize("@ss.hasPermi('web:history:page')")
    @GetMapping("/page")
    public Result<List<IotCubeElectricityConsumptionHistory>> page(IotCubeElectricityConsumptionHistory iotCubeElectricityConsumptionHistory)
    {
        startPage();
        List<IotCubeElectricityConsumptionHistory> list = iotCubeElectricityConsumptionHistoryService.selectIotCubeElectricityConsumptionHistoryList(iotCubeElectricityConsumptionHistory);
        return getPageTable(list);
    }

    /**
     * 查询IoT数据_六面控温用电量记录列表
     */
    @ApiOperation(value = "查询IoT数据_六面控温用电量记录列表")
    @PreAuthorize("@ss.hasPermi('web:history:list')")
    @GetMapping("/list")
    public Result<List<IotCubeElectricityConsumptionHistory>> list(IotCubeElectricityConsumptionHistory iotCubeElectricityConsumptionHistory)
    {
        List<IotCubeElectricityConsumptionHistory> list = iotCubeElectricityConsumptionHistoryService.selectIotCubeElectricityConsumptionHistoryList(iotCubeElectricityConsumptionHistory);
        return Result.ok(list);
    }

    /**
     * 导出IoT数据_六面控温用电量记录列表
     */
    @ApiOperation(value = "导出IoT数据_六面控温用电量记录列表")
    @PreAuthorize("@ss.hasPermi('web:history:export')")
    @Log(title = "IoT数据_六面控温用电量记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IotCubeElectricityConsumptionHistory iotCubeElectricityConsumptionHistory)
    {
        List<IotCubeElectricityConsumptionHistory> list = iotCubeElectricityConsumptionHistoryService.selectIotCubeElectricityConsumptionHistoryList(iotCubeElectricityConsumptionHistory);
        ExcelUtil<IotCubeElectricityConsumptionHistory> util = new ExcelUtil<IotCubeElectricityConsumptionHistory>(IotCubeElectricityConsumptionHistory.class);
        util.exportExcel(response, list, "IoT数据_六面控温用电量记录数据");
    }

    /**
     * 获取IoT数据_六面控温用电量记录详细信息
     */
    @ApiOperation(value = "获取IoT数据_六面控温用电量记录详细信息")
    @PreAuthorize("@ss.hasPermi('web:history:query')")
    @GetMapping(value = "/{id}")
    public Result<IotCubeElectricityConsumptionHistory> getInfo(@PathVariable("id") Long id)
    {
        return Result.ok(iotCubeElectricityConsumptionHistoryService.selectIotCubeElectricityConsumptionHistoryById(id));
    }

    /**
     * 新增IoT数据_六面控温用电量记录
     */
    @ApiOperation(value = "新增IoT数据_六面控温用电量记录")
    @PreAuthorize("@ss.hasPermi('web:history:add')")
    @Log(title = "IoT数据_六面控温用电量记录", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody IotCubeElectricityConsumptionHistory iotCubeElectricityConsumptionHistory)
    {
        return Result.ok(iotCubeElectricityConsumptionHistoryService.insertIotCubeElectricityConsumptionHistory(iotCubeElectricityConsumptionHistory));
    }

    /**
     * 修改IoT数据_六面控温用电量记录
     */
    @ApiOperation(value = "修改IoT数据_六面控温用电量记录")
    @PreAuthorize("@ss.hasPermi('web:history:edit')")
    @Log(title = "IoT数据_六面控温用电量记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody IotCubeElectricityConsumptionHistory iotCubeElectricityConsumptionHistory)
    {
        return Result.ok(iotCubeElectricityConsumptionHistoryService.updateIotCubeElectricityConsumptionHistory(iotCubeElectricityConsumptionHistory));
    }

    /**
     * 删除IoT数据_六面控温用电量记录
     */
    @ApiOperation(value = "删除IoT数据_六面控温用电量记录")
    @PreAuthorize("@ss.hasPermi('web:history:remove')")
    @Log(title = "IoT数据_六面控温用电量记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return Result.ok(iotCubeElectricityConsumptionHistoryService.deleteIotCubeElectricityConsumptionHistoryByIds(ids));
    }

    @ApiOperation(value = "获取能耗详情")
    @GetMapping("/getEnergyConsumption")
    public Result getEnergyConsumption(IotCubeElectricityConsumptionHistory query) {
        return Result.ok(iotCubeElectricityConsumptionHistoryService.getTotalEnergyConsumption(query));
    }
}
